package array

// 类似IndexOf, 从右向左找
func LastIndexOf /*[T any]*/ (array []T, value T, fromIndex ...int) int {
	startIndex := len(array) - 1
	if len(fromIndex) > 0 {
		startIndex = fromIndex[0]
	}
	if startIndex > len(array)-1 {
		startIndex = len(array) - 1
	}
	for i := startIndex; i >= 0; i-- {
		if array[i] == value {
			return i
		}
	}
	return -1
}